//
//  CTCTabBarController.m
//  ConsultantVersion
//
//  Created by 李小龙 on 2017/3/25.
//  Copyright © 2017年 jieshuibao. All rights reserved.
//

#import "CTCTabBarController.h"
#import "CTCTabBar.h"
#import "CTCNavigationController.h"
#import "CTCResponderVC.h"
#import "CTCAnswerConsultVC.h"
#import "CTCFinanceTaxCircleVC.h"
#import "CTCMyTableViewController.h"
#import "CTCNavigationController.h"
#import "UITabBarItem+DKSBadge.h"
#import "CTCContractVC.h"
#import "CTCMyArticleVC.h"

@interface CTCTabBarController ()

@end

@implementation CTCTabBarController

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    
    // 初始化子控制器
    CTCResponderVC *responderVC = [CTCResponderVC viewControllerFromStoryboard];
    [self addChildViewController:responderVC title:@"抢答" image:@"answer" selectedImage:@"q"];
    
    UIStoryboard *story = [UIStoryboard storyboardWithName:@"CTCResponderVC" bundle:nil];
    CTCAnswerConsultVC *answerVC = [story instantiateViewControllerWithIdentifier:@"CTCAnswerConsultVC"];
    [self addChildViewController:answerVC title:@"回答" image:@"consulting" selectedImage:@"组6副本7"];

    
    CTCFinanceTaxCircleVC *vc = [CTCFinanceTaxCircleVC viewControllerFromStoryboard];
    CTCNavigationController *nav = [[CTCNavigationController alloc ]initWithRootViewController:vc];
    // 添加子控制器
    [self addChildViewController:nav];
    
//    CTCContractVC *contractVC = [CTCContractVC viewControllerFromStoryboard];
//    [self  addChildViewController:contractVC title:@"合同审核" image:@"audit" selectedImage:@"h"];
    
    CTCMyArticleVC *myArticleVC = [[CTCMyArticleVC alloc]init];
    [self addChildViewController:myArticleVC title:@"我的文章" image:@"文章" selectedImage:@"文章副本"];
    
    CTCMyTableViewController *myVC = [CTCMyTableViewController viewControllerFromStoryboard];
    
    [self addChildViewController:myVC title:@"我的" image:@"我副本" selectedImage:@"我"];
    
    
    CTCTabBar *tabBar = [[CTCTabBar alloc]init];
    [self setValue:tabBar forKey:@"tabBar"];
}


- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
}

-(void)addChildViewController:(UIViewController *)childController title:(NSString *)title image:(NSString *)image selectedImage:(NSString *)selectedImage
{
    childController.title = title;
    childController.tabBarItem.image = [UIImage imageNamed:image];
    childController.tabBarItem.selectedImage = [[UIImage imageNamed:selectedImage] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    
    NSDictionary *dicNor = @{
                             NSForegroundColorAttributeName:HEXCOLOR(0x666666),
                             NSFontAttributeName:SYSTEMFONT(10)
                             };
    
    [childController.tabBarItem setTitleTextAttributes:dicNor forState:UIControlStateNormal];
    
    NSDictionary *dicSelected = @{
                                  NSForegroundColorAttributeName:HEXCOLOR(0x1777cb),
                                  NSFontAttributeName:SYSTEMFONT(10)
                                  };
    
    
    
    [childController.tabBarItem setTitleTextAttributes:dicSelected forState:UIControlStateSelected];
    
    // 先把外面传进来的控制器包装成一个导航控制器
    CTCNavigationController *nav = [[CTCNavigationController alloc ]initWithRootViewController:childController];
    // 添加子控制器
    [self addChildViewController:nav];
}


@end
